//
//  ZWPropertyReceiveController.m
//  NewProject
//
//  Created by tongtong on 2018/5/19.
//  Copyright © 2018年 chenIos. All rights reserved.
//

#import "ZWPropertyReceiveController.h"
#import "ZCIFiter.h"
@interface ZWPropertyReceiveController ()
{
    UILabel *keyLabel;
}
@end

@implementation ZWPropertyReceiveController
-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBarHidden = YES;

}
-(void)gotoback{
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = COLOR_WHITE;
    
    
    UIView *backView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_W, Scare_Width(182))];
    backView.backgroundColor = COLOR_BLUE;
    [self.view addSubview:backView];
    
    UIButton *btn = [[UIButton alloc]init];
    btn.frame = CGRectMake(Scare_Width(10), Scare_Width(25), 44, 44);
    [btn setImage:[UIImage imageNamed:@"back_close"] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(gotoback) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];

    
    UILabel *lab = [[UILabel alloc]init];
    lab.frame = CGRectMake(100, Scare_Width(40), SCREEN_W - 200, Scare_Width(25));
    lab.font = H_Medium2;
    lab.textColor = COLOR_WHITE;
    lab.text = Z_Location(@"receivingCode");
    lab.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:lab];
    
    UIImageView *imagView = [[UIImageView alloc]init];
    imagView.frame = CGRectMake(SCREEN_W/2 - Scare_Width(30), Scare_Width(152), Scare_Width(60), Scare_Width(60));
    imagView.image = [UIImage imageNamed:@"receiveImag"];
    [self.view addSubview:imagView];
    
//    ZWalletAccount *wallet = [ZWalletAccount wallet];

    keyLabel = [[UILabel alloc]init];
    keyLabel.text = self.walletInfo.walletAdress;
    keyLabel.frame = CGRectMake(Scare_Width(50), Scare_Width(242), SCREEN_W - Scare_Width(100), 50);
    keyLabel.numberOfLines = 0;
    keyLabel.font = H_Medium3;
    keyLabel.textColor = COLOR_MIDDLE_GRAY;
    [self.view addSubview:keyLabel];
    
    UIImageView *filterImage = [[UIImageView alloc]init];
    filterImage.frame = CGRectMake(SCREEN_W/2 - Scare_Width(100), Scare_Width(242  + 20)+ 50, Scare_Width(200), Scare_Width(200));
    filterImage.image = [ZCIFiter createFiter:self.walletInfo.walletAdress];
    [self.view addSubview:filterImage];
    
    UIButton *copyBtn = [[UIButton alloc]init];
    CGFloat bottom = iPhoneX ? 34 : 0;
    copyBtn.frame =  CGRectMake(Scare_Width(20), SCREEN_H - Scare_Width(60)-bottom, SCREEN_W - Scare_Width(40), Scare_Width(50));
    [copyBtn setTitle:Z_Location(@"copyWalletAddress") forState:UIControlStateNormal];
    [copyBtn addTarget:self action:@selector(copyMessageMethod) forControlEvents:UIControlEventTouchUpInside];
    copyBtn.titleLabel.font = H_Medium2;
    [copyBtn setTitleColor:COLOR_MIDDLE_GRAY forState:UIControlStateNormal];
    [copyBtn setBackgroundColor:[UIColor colorWithHexString:@"eff1f2"]];
    [self.view addSubview:copyBtn];
}
#pragma mark ---复制收款码--
-(void)copyMessageMethod{
    [self.view makeToast:Z_Location(@"copySuccess") duration:2.0f position:CSToastPositionCenter];
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    pasteboard.string = keyLabel.text;

}


@end
